home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kbuttonbox.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  5.5 KB  |  171 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 1997 Mario Weilguni (mweilguni@sime.com)
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.  
  9.     This library is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.     Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public License
  15.     along with this library; see the file COPYING.LIB.  If not, write to
  16.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.     Boston, MA 02110-1301, USA.
  18. */
  19.  
  20. #ifndef __KBUTTONBOX__H__
  21. #define __KBUTTONBOX__H__
  22.  
  23. #include <kdelibs_export.h>
  24.  
  25. #include <qwidget.h>
  26. class QPushButton;
  27. class KGuiItem;
  28.  
  29. class KButtonBoxPrivate;
  30. /**
  31.  * Container widget for buttons.
  32.  *
  33.  * This class uses Qt layout control to place the buttons; can handle
  34.  * both vertical and horizontal button placement.  The default border
  35.  * is now @p 0 (making it easier to deal with layouts). The space
  36.  * between buttons is now more Motif compliant.
  37.  *
  38.  * @author Mario Weilguni <mweilguni@sime.com>
  39.  * @version $Id: kbuttonbox.h 465272 2005-09-29 09:47:40Z mueller $
  40.  **/
  41.  
  42. class KDEUI_EXPORT KButtonBox : public QWidget
  43. {
  44.   Q_OBJECT
  45.  
  46. public:
  47.   /**
  48.     * Create an empty container for buttons.
  49.     *
  50.     * If @p _orientation is @p Vertical, the buttons inserted with
  51.     * addButton() are laid out from top to bottom, otherwise they
  52.     * are laid out from left to right.
  53.     */
  54.   KButtonBox(QWidget *parent, Orientation _orientation = Horizontal,
  55.          int border = 0, int _autoborder = 6);
  56.  
  57.   /**
  58.     * Free private data field
  59.     */
  60.   ~KButtonBox();
  61.  
  62.   /**
  63.     * @return The minimum size needed to fit all buttons.
  64.     *
  65.     * This size is
  66.     * calculated by the width/height of all buttons plus border/autoborder.
  67.     */
  68.   virtual QSize sizeHint() const;
  69.   virtual QSizePolicy sizePolicy() const;
  70.   virtual void resizeEvent(QResizeEvent *);
  71.  
  72.   /**
  73.     * Add a new QPushButton.
  74.     *
  75.     * @param text the text of the button to add
  76.     * @param noexpand If @p noexpand is @p false, the width
  77.     * of the button is adjusted to fit the other buttons (the maximum
  78.     * of all buttons is taken). If @p noexpand is @p true, the width of this
  79.     * button will be set to the minimum width needed for the given text).
  80.     *
  81.     * @return A pointer to the new button.
  82.     */
  83.   QPushButton *addButton(const QString& text, bool noexpand = false);
  84.  
  85.   /**
  86.     * Add a new QPushButton.
  87.     *
  88.     * @param text the text of the button to add.
  89.     * @param receiver An object to connect to.
  90.     * @param slot A Qt slot to connect the 'clicked()' signal to.
  91.     * @param noexpand If @p noexpand is @p false, the width
  92.     * of the button is adjusted to fit the other buttons (the maximum
  93.     * of all buttons is taken). If @p noexpand @p true, the width of this
  94.     * button will be set to the minimum width needed for the given text).
  95.     *
  96.     * @return A pointer to the new button.
  97.     */
  98.   QPushButton *addButton(const QString& text, QObject * receiver, const char * slot, bool noexpand = false);
  99.  
  100.   /**
  101.     * Add a new QPushButton.
  102.     *
  103.     * @param guiitem text and icon on the button
  104.     * @param noexpand If @p noexpand is @p false, the width
  105.     * of the button is adjusted to fit the other buttons (the maximum
  106.     * of all buttons is taken). If @p noexpand is @p true, the width of this
  107.     * button will be set to the minimum width needed for the given text).
  108.     *
  109.     * @return A pointer to the new button.
  110.     *
  111.     * @since 3.3
  112.     */
  113.   QPushButton *addButton(const KGuiItem& guiitem, bool noexpand = false);
  114.  
  115.   /**
  116.     * Add a new QPushButton.
  117.     *
  118.     * @param guiitem text and icon on the button
  119.     * @param receiver An object to connect to.
  120.     * @param slot A Qt slot to connect the 'clicked()' signal to.
  121.     * @param noexpand If @p noexpand is @p false, the width
  122.     * of the button is adjusted to fit the other buttons (the maximum
  123.     * of all buttons is taken). If @p noexpand @p true, the width of this
  124.     * button will be set to the minimum width needed for the given text).
  125.     *
  126.     * @return A pointer to the new button.
  127.     *
  128.     * @since 3.3
  129.     */
  130.   QPushButton *addButton(const KGuiItem& guiitem, QObject * receiver, const char * slot, bool noexpand = false);
  131.  
  132.   /**
  133.     * Add a stretch to the buttonbox.
  134.     *
  135.     * Can be used to separate buttons.  That is, if you add the
  136.     * buttons OK and Cancel, add a stretch, and then add the button Help,
  137.     * the buttons OK and Cancel will be left-aligned (or top-aligned
  138.     * for vertical) whereas Help will be right-aligned (or
  139.     * bottom-aligned for vertical).
  140.     *
  141.     * @see QBoxLayout
  142.     */
  143.   void addStretch(int scale = 1);
  144.  
  145.   /**
  146.     * This function must be called @em once after all buttons have been
  147.     * inserted.
  148.     *
  149.     * It will start layout control.
  150.     */
  151.   void layout();
  152.  
  153. public: // as PrivateData needs Item, it has to be exported
  154.   class Item;
  155. protected:
  156.   /**
  157.     * @return the best size for a button. Checks all buttons and takes
  158.     * the maximum width/height.
  159.     */
  160.   QSize bestButtonSize() const;
  161.   void  placeButtons();
  162.   QSize buttonSizeHint(QPushButton *) const;
  163.  
  164. protected:
  165.   virtual void virtual_hook( int id, void* data );
  166. private:
  167.   KButtonBoxPrivate* const data;
  168. };
  169.  
  170. #endif
  171.